package com.tian.service;

import com.tian.dto.LoanApplyDto;
import com.tian.entity.LoanApply;
import com.tian.enums.ResultCode;
import com.tian.mapper.LoanApplyMapper;
import com.tian.utils.CommonResult;
import com.tian.utils.LoanApplyDataConvertUtil;
import org.apache.dubbo.config.annotation.Service;

import javax.annotation.Resource;

/**
 * @author tianwc  公众号：java后端技术全栈、面试专栏
 * @version 1.0.0
 * @date 2023年08月28日 10:52
 * 在线刷题 1200+题和1000+篇干货文章：<a href="https://woaijava.cc/">博客地址</a>
 */
@Service(version = "1.0.0")
public class LoanApplyServiceImpl implements LoanApplyDubboService {

    @Resource
    private LoanApplyMapper loanApplyMapper;

    @Override
    public CommonResult<LoanApplyDto> queryLoanApplyById(Long id) {
        LoanApply loanApply = loanApplyMapper.selectByPrimaryKey(id);
        if (loanApply == null) {
            return CommonResult.failed(ResultCode.PARAMETER_ERROR);
        }
        LoanApplyDto loanApplyDto = LoanApplyDataConvertUtil.convert(loanApply);
        return CommonResult.success(loanApplyDto);
    }
}
